<template>
	<el-dialog title="" visible :show-close="false" :modal-append-to-body="false" class="wrap" size="tiny">
		 <div class="bt">{{this.form.zwm}}-退费</div>
		<i class="el-icon-close close" @click="cancel" style="color: white;"></i>
		<el-form label-width="100px" class="form">
			<el-form-item label="学生名称">
				  <el-input v-model="form.zwm"  icon="info" class="select-block"></el-input>
			</el-form-item>
			 <el-form-item label="可退金额">
                <el-input v-model="form.ycje" :readonly="true" class="select-block"></el-input>
            </el-form-item>
			<el-form-item label="退费金额">
				  <el-input v-model="tfje" type="number"  class="select-block"></el-input>
			</el-form-item>
			<!--<el-form-item label="退费收款类型">
				  <el-input v-model="form.tfsklx"  class="select-block"></el-input>
			</el-form-item>
			<el-form-item label="退费收款账号">
				  <el-input v-model="form.tfzh"  class="select-block"></el-input>
			</el-form-item>-->
			<el-form-item label="退费原因">
				  <!-- <el-input v-model="form.ms" :readonly="true" icon="info" class="select-block"></el-input>-->
				  <el-input v-model="form.tfyy" type="textarea"  :rows="4"   icon="info" class="select-block"></el-input>
			</el-form-item>
			
					<el-table :data="xwcjdataList" stripe style="width: 100%">
						<el-table-column prop="kcmc" label="课程名称"></el-table-column>
						<el-table-column prop="lx" label="类型"></el-table-column>
						<el-table-column prop="ysks" label="已上课时"></el-table-column>
						<el-table-column prop="kxje" label="课消金额"></el-table-column>
						<el-table-column prop="jzsj" label="结转时间" width='150px'></el-table-column>
						<el-table-column prop="jzje" label="结转金额"></el-table-column>
					</el-table>

		</el-form>
		<el-button type="primary" class="submit" @click="loadinfo">确定</el-button>
		<el-button type="danger" class="submit" @click="cancel">退出</el-button>
	</el-dialog>
</template>

<script type="text/javascript">
	import qs from 'qs'
	export default {
		props: ['params'],
		data() {
			return {
				xwcjdataList:[],
				form: {
					zwm:'',
					tfyy:'',
					tfsklx:'',
					tfzh:'',
					ktyuer:'',
					ycje:'',
					xsid:''
				},
				tfje:'',
			}
		},
		created() {
		   console.log(this.params,'ssssssssssss')
           this.form.zwm=this.params.row.zwm;
           this.form.ycje=this.params.row.ycje;
           this.form.xsid=this.params.row.id;
			this.xwcj();


		},
				 watch:{
            'tfje': function(newVal,oldVal){
                if(parseInt(newVal) > parseInt(this.form.ycje)) {//如果小于等于零
//                  this.tfje = this.form.yuer//恢复原值
					this.tfje = 0.00
                    this.$message.warning('输入余额超过可退余额!')
                }
            }
        },
		methods: {
			xwcj() {
				var logininfo = JSON.parse(localStorage.logininfo);
				this.searchLoading = true;
				var params2 = qs.stringify({
					xsid: this.form.xsid,
					yhid: logininfo.id,
					xxid: logininfo.xxid,
				})
				//执行
				this.axios.post(this.$store.state.api + 'xs/tfjexq', params2)
					.then(res => {
						console.log(res,'llllllllllllllllll')
						let data = res.data.data;
						let list = data.list;
						this.xwcjdataList = list;
						this.searchLoading = false;
					}).catch(res => {
						console.log(res)
						this.searchLoading = false;
					})

			},
			loadinfo(){
				 var logininfo = JSON.parse(localStorage.logininfo) ;
				 var params3 = qs.stringify({
                             yhid:logininfo.id,
							 xxid:logininfo.xxid,
							 xsid:this.form.xsid,
							 tfje:this.tfje,
							 tfyy:this.form.tfyy,

						});
				 this.axios.post(this.$store.state.api+'xstf/add',params3)
				 .then( res =>  {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'info1', cancel: false });
							this.$message.success(res.data.msg);
							this.$store.state.loading = false;
						} else {
						    this.$message.warning(res.data.msg);
							this.$store.state.loading = false;
						}
					 }).catch(res => {
						 this.$message.danger("服务器异常");
			 				this.$store.state.loading = false;
					 })
			},
			cancel() {
				this.$emit('close', { type: 'info1', cancel: true })
			},
			},
	}
</script>

<style lang="less" scoped>
	.wrap {
		text-align: center;
	}
	.bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top:0;
			left:0;
			background: #50BFFF;
			margin-bottom: 20px;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
	.form {
		text-align: left;
		margin-top: 15px;
	}
	.select-block {
		display: block;
	}

	.submit {
		width: 120px;
		margin-top: 8px;
	}
</style>
